<?php
/**
 * Created by IntelliJ IDEA.
 * User: TinND
 * Date: 4/3/14
 * Time: 1:57 PM
 */
include '../connection.php';

$data = json_decode(file_get_contents("php://input"));
if (isset($data->api)) {
    mysql_query("SET NAMES 'utf8'");

    switch ($data->api) {
        case 3222:
            $query = "
            UPDATE  `u887941657_nitin`.`Product` SET
            `name` =  '$data->name',
            `description` =  '$data->description',
            `type` =  '$data->type',
            `price` =  '$data->price',
            `status` =  '$data->status',
            `created` =  '$data->created'
            WHERE  `Product`.`id` =$data->id;" . "";
            $result = mysql_query($query, $link) or die('Errant query:  ' . $query);

            header('Content-type: application/json');
            $answer = array('success' => 'true');
            echo json_encode($answer);
            break;
        case 3223:
            break;
        case 3224:
            break;
    }
} else {
    echo json_encode(array('success' => 'false '));
}
@mysql_close($link);